import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    LoginState:JSON.parse(sessionStorage.getItem('user'))||[],
    Dselected:0,
    Search:JSON.parse(sessionStorage.getItem('search'))||[]
  },
  getters: {
  },
  mutations: {
    setLoginState(state,value){
      console.log(value)
      let user =JSON.stringify(value)
      sessionStorage.setItem('user',user)
      state.LoginState = value
      // console.log('完成')
    },
    pushSearch(state,value){
      if(state.Search.some(v=>v==value)) return  console.log('相同')
      state.Search.push(value)
      sessionStorage.setItem('search',JSON.stringify(state.Search))
      state.Search=JSON.parse(sessionStorage.getItem('search'))
    }
  },
  actions: {
  },
  modules: {
  }
})
